<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>
<link href="__ROOT__/Application/Admin/Public/css/cropper/cropper.min.css" rel="stylesheet">
<link href="__ROOT__/Application/Admin/Public/css/main.css" rel="stylesheet">
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.config.js"/>
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.all.min.js"/>
<js href="__ROOT__/Application/Admin/Public/js/jquery-2.0.2.js"/>

<!--编辑器-->
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.config.js"/>
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.all.min.js"/>
<script>
    $(function () {
        var ue = UE.getEditor('container');
    });
</script>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">添加/编辑书籍</h1>
            </div>
        </div>

        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                            <div class="panel panel-default">
                                <div class="panel-heading" role="tab" id="headingOne">
                                    <h4 class="panel-title">
                                        <a role="button" data-toggle="collapse" data-parent="#accordion"
                                           href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                            添加/编辑书籍
                                        </a>
                                    </h4>
                                </div>
                                <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                                     aria-labelledby="headingOne">
                                    <div class="panel-body">
                                        <form id="editStoreForm" action="{:U('EditBook')}"
                                              class="form-horizontal"
                                              method="post">

                                            <input id="BOOK_ID" name="ID" type="hidden" value="{$DATA['ID']}">

                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">商品主图:</label>

                                                <div class="col-sm-10">
                                                    <div class="goods-img-list">
                                                        <div class="goods-img-item">
                                                            <img style="height: 250px;"
                                                                 src="{$DATA['PIC_URL']}" alt="">
                                                            <span class="glyphicon close-goods-img glyphicon-remove-circle"></span>
                                                        </div>

                                                        <div class="goods-img-item">
                                                            <img height="100px" class="add-goods-img avatar-view"
                                                                 src="__ROOT__/Application/Admin/Public/images/default.png"
                                                                 alt=""
                                                                 style="margin-left:20px">
                                                        </div>

                                                    </div>
                                                    <p class="help-block" style="display: none">上传图片</p>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">一级分类:</label>

                                                <div class="col-sm-3">
                                                    <select id="status" type="text" class="form-control"
                                                            name="region_one">
                                                        <option value="{$DATA['region_one']}">{$DATA['region_one']}
                                                        </option>
                                                        <foreach name="yjfldata" item="v" key="k">
                                                            <option value="{$v.region_id}">{$v.region_name}</option>
                                                        </foreach>
                                                    </select>
                                                </div>
                                                <label class="col-sm-2 control-label">二级分类:</label>

                                                <div class="col-sm-3">

                                                    <select id="two" type="text" class="form-control" name="region_two">
                                                        <option value="{$DATA['region_two']}">{$DATA['region_two']}
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍名称:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="TITLE"
                                                           value="{$DATA['TITLE']}">
                                                </div>
                                                <label class="col-sm-2 control-label">条形码ISBN:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="ISBN"
                                                           value="{$DATA['ISBN']}">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">丛书名:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="TITLE_C"
                                                           value="{$DATA['TITLE_C']}">
                                                </div>
                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">作者:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="AUTHOR"
                                                           value="{$DATA['AUTHOR']}">
                                                </div>

                                                <label class="col-sm-2 control-label">出版社:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="PRESS"
                                                           value="{$DATA['PRESS']}">
                                                </div>

                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">出版日期:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="PUBLICATION_DATE"
                                                           value="{$DATA['PUBLICATION_DATE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">包装规格:</label>

                                                <div class="col-sm-3">

                                                    <select type="text" class="form-control"
                                                            name="PACKING_SPECIFICATION">
                                                        <option value="{$DATA['PACKING_SPECIFICATION']}">
                                                            {$DATA['PACKING_SPECIFICATION']}
                                                        </option>
                                                        <foreach name="BOOK_PACKING" item="v" key="k">
                                                            <option value="{$v.region_name}">{$v.region_name}</option>
                                                        </foreach>
                                                    </select>
                                                </div>

                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">阅读年龄:</label>

                                                <div class="col-sm-3">
                                                    <input class="form-control" name="AGE" value="{$DATA.AGE}"
                                                           readonly="readonly" id="AGE" onclick="AGECHANGE($(this))">
                                                    <ul class="list-group" hidden>
                                                        <foreach name="BOOK_AGE" item="v" key="k">
                                                            <li class="list-group-item">
                                                                <input onclick="SelectAge()" type="checkbox"
                                                                       name="checkbox" value="{$v.region_name}">
                                                                {$v.region_name}
                                                            </li>
                                                        </foreach>
                                                    </ul>
                                                    </ul>
                                                </div>


                                                <label class="col-sm-2 control-label">库存:</label>

                                                <div class="col-sm-3">
                                                    <input type="number" class="form-control" name="STOCK" min="0"
                                                           id="STOCK" readonly="readonly">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">原价:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" id="Y_PRICE" name="Y_PRICE"
                                                           value="{$DATA['Y_PRICE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">销售价格:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="XS_PRICE"
                                                           value="{$DATA['XS_PRICE']}" readonly="readonly">
                                                </div>
                                            </div>
                                            <!--<div class="form-group">-->
                                            <!--<label class="col-sm-2 control-label">书籍新旧水平:</label>-->

                                            <!--<div class="col-sm-3">-->
                                            <!--<select type="text" class="form-control" name="LEVEL">-->
                                            <!--<option value="{$DATA['LEVEL']}">{$DATA['LEVEL']}</option>-->
                                            <!--<foreach name="BOOK_LEVEL" item="v" key="k">-->
                                            <!--<option value="{$v.region_name}">{$v.region_name}</option>-->
                                            <!--</foreach>-->
                                            <!--</select>-->

                                            <!--</div>-->

                                            <!--<label class="col-sm-2 control-label">借阅次数:</label>-->

                                            <!--<div class="col-sm-3">-->
                                            <!--<input type="number" class="form-control" name="BORROW_NUM"-->
                                            <!--value="{$DATA['BORROW_NUM']}" readonly="readonly">-->
                                            <!--</div>-->
                                            <!--</div>-->
                                            <div class="form-group">


                                                <label class="col-sm-2 control-label">语言:</label>

                                                <div class="col-sm-3">
                                                    <select type="text" class="form-control" name="LANGUAGES">
                                                        <option value="{$DATA['LANGUAGES']}">{$DATA['LANGUAGES']}
                                                        </option>
                                                        <foreach name="BOOK_LANGUAGES" item="v" key="k">
                                                            <option value="{$v.region_name}">{$v.region_name}</option>
                                                        </foreach>
                                                    </select>
                                                </div>

                                                <label class="col-sm-2 control-label">书籍状态:</label>

                                                <div class="col-sm-3">
                                                    <select type="text" class="form-control" name="STATE">
                                                        <option value="{$DATA['STATE']}">{$DATA['STATE']}</option>
                                                        <foreach name="BOOK_STATE" item="v" key="k">
                                                            <option value="{$v}">{$v}</option>
                                                        </foreach>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">音频链接:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="BOOK_VIDEO"
                                                           value="{$DATA['BOOK_VIDEO']}">
                                                </div>
                                                <label class="col-sm-2 control-label">音频链接时长(秒):</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="BOOK_VIDEO_TIME"
                                                           value="{$DATA['BOOK_VIDEO_TIME']}">
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍简介:</label>

                                                <div class="col-sm-8">
                                                    <textarea type="text" class="form-control" name="INFO" rows="4">{$DATA['INFO']}</textarea>
                                                </div>
                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">书籍详情:</label>

                                                <div class="col-sm-8">
                                                    <script id="container" id="CONTENT" name="CONTENT"
                                                            type="text/plain" required>{$DATA.details}



















































                                                    </script>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <div class="col-sm-2 col-sm-offset-2">
                                                    <button type="submit" class="btn btn-block btn-primary">保存</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>


<include file="CommonSidebar:common-script"/>
<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/uploadPreview.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.form.min.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.qrcode.min.js"></script>


<include file="Common:common-cropper-qiniu"/>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/bootstrapValidator.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/cropper/cropper.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/figureForqiniu.js?v=2"></script>


</body>
<script>
    //显示隐藏年龄段
    function BQ_CHANGE(elem) {
        $("#BOOK_BQ").modal("show");
    }


    //显示隐藏年龄段
    function AGECHANGE(elem) {
        if (elem.next().is(":hidden")) {
            elem.next().show();
        } else {
            elem.next().hide();
        }
    }
    //选择年龄
    function SelectAge() {
        var vals = '';
        $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
            vals += $(this).val();
            vals += ',';
        });
        $("#AGE").val(vals);
    }


</script>
<script>
    $(function () {
        new CropAvatar({
            container: '#crop-avatar',
            workspaces: '__ROOT',
            formUrl: "http://upload-z2.qiniup.com",  //华南地区
            tokenUrl: "http://www.youthtech.com.cn/php-sdk-master/examples/upload_token_book.php",  //华南地区
            submitDone: function (data) {
                console.log(data);
                var $avatarView = $('.avatar-view');
                if (data.picpath) {
                    var imgUrl = 'http://pic.qimiaoyue.com/' + data.picpath + data.crop;
                    var html = ' <div class="goods-img-item">';
                    html += '<img style="height: 250px" src="' + imgUrl + '" alt="">';
                    html += '<span class="glyphicon close-goods-img glyphicon-remove-circle"></span>';
                    html += ' <input type="hidden" value="' + imgUrl + '" name="PIC_URL" >';
                    html += '</div>';
                    $avatarView.before(html);
                    $avatarView.hide();
                }
            },
            delete: function (e) {
                var _this = e.target;
                var flag = _this.className.indexOf('close-goods-img');
                var $avatarView = $('.avatar-view');
                if (flag >= 0) {
                    var $elem = $(_this);
                    if (confirm("确认移除？")) {
                        $avatarView.show();
                        $elem.parent(".goods-img-item").remove();
                        $avatarView.next("input[name='thumbpicpath']").val("");
                        $avatarView.next("input[name='picpath']").val("");
                        $('.add-goods-img').attr('src', options.workspaces + '/Public/Boss/images/default.png')
                    }
                }
            }

        });
    });

    function submitcheck() {
        var $picid = $("input[name='picid']");
        if ($picid.val() == "") {
            $picid.parents(".form-group").removeClass("has-success").addClass("has-error");
            $picid.parents(".form-group").find(".help-block").show();
            return false;
        }
    }
</script>
</html>
